home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr48 / pavt150.zip / PAVTDEMO.PAS < prev    next >
Pascal/Delphi Source File  |  1993-04-12  |  4KB  |  122 lines

  1. program PAvtDemo; { Demo of Avatar level 1 console using Crt routines }
  2.                   { Public Domain.  Author: Gregory P. Smith          }
  3.                   { Modification History:                             }
  4.                   {        12/23/91   Added coordinate checks on all  }
  5.                   {                   Screen Manipluations            }
  6.                   {        08/21/92   Added VT-52 & AdLib support     }
  7.                   {        10/17/92   Changed AVT/0+ to the default   }
  8.                   {                   Terminal.                       }
  9.                   {        01/30/93   Allowed music to finish playing }
  10.                   {                   before exiting.                 }
  11.                   {        04/07/93   Cleaned up and added comments.  }
  12. {$R-,F-,M 4096,4096,4096}
  13.  
  14. Uses Dos, Crt,
  15.      PAvtIO, PAvtSnd, PAvt150;
  16.  
  17. {$IFNDEF ST}
  18. {$I DHOOKS.INC -- link in the screen I/O and user hooks. }
  19. {$ENDIF}
  20.  
  21. function UpStr(s:string): string;
  22. var
  23.   ns : string;
  24.   i : integer;
  25. begin
  26.   for i := 1 to length(s) do
  27.     ns[i] := upcase(s[i]);
  28.   ns[0] := s[0];  { copy the length byte }
  29.   UpStr := ns;
  30. end;
  31.  
  32. procedure Help(long:boolean);
  33. begin
  34.   Writeln('PAvatar 1.50 Demo -- Copr. 1993 Gregory P. Smith'^M^J);
  35.   Writeln('Usage:  pavtdemo [params] input_file [params]');
  36.   if long then
  37.    begin
  38.      Writeln;
  39.      Writeln(' parameters (may be abbreviated):');
  40.      Writeln('   /AVT1         Emulate a full Avatar level 1 terminal. (*)');
  41.      Writeln('   /ANSI         Emulate an ANSI-BBS terminal. (*)');
  42.      Writeln('   /VT52         Emulate a VT-52 terminal. (*)');
  43.      Writeln('   /SLOW         Slow down emulation for easier viewing.');
  44.      Writeln('   /NOFM         Do NOT use AdLib / SoundBlaster FM music for sounds.');
  45.      Writeln;
  46.      Writeln(' (*) Avatar level 0+ with ANSI-BBS fallback is the default terminal.');
  47.    end
  48.   else Writeln(' type pavtdemo /? for more help');
  49.   halt;
  50. end;
  51.  
  52. var
  53.   fname : pathstr;  { name of file to display }
  54.   slowdown : byte;  { ms to delay between characters }
  55.  
  56. procedure ProcessParams;
  57. const
  58.   Prms = '/AVT1/ANSI/SLOW/?/HELP/VT52/NOFM';
  59. var
  60.   t : TerminalType;
  61.   i,p : byte;
  62. begin
  63.   p := paramcount;
  64.   if p = 0 then Help(False);
  65.   t := TermAVT0;   { AVT/0+ with fallback is default }
  66.   slowdown := 0;   { default to full speed }
  67.   while p > 0 do
  68.    begin
  69.      i := pos(UpStr(ParamStr(p)),Prms);
  70.      case i of
  71.        1  : t := TermAVT1;
  72.        6  : t := TermANSI;
  73.        11 : Slowdown := 1; { set to ms between chars. }
  74.        16..18 : Help(True);
  75.        23 : t := TermVT52;
  76.        28 : Use_AdLib := False;
  77.      else
  78.       fname := ParamStr(p);
  79.      end; { case }
  80.      dec(p);
  81.    end; { while }
  82.   SetTerminal(t);
  83. end;  { processed in reverse so that first non-parameter is the filename }
  84.  
  85. var
  86.   f : file;
  87.   buf : Array[1..1024] of char;
  88.   i,z : word;
  89.  
  90. BEGIN
  91.   InitUnit;  { Initialize the PAvatar unit }
  92. {$IFNDEF ST}
  93.   Assign(Output,''); Rewrite(Output);
  94.   Assign(Input,''); Reset(Input);
  95. {$ENDIF}
  96.   fname := '';
  97. {$IFNDEF ST}
  98.   SetScrPtr;  { Initialize the video routines (dhooks.inc) }
  99.   SetHooks;   { Initialize the I/O hooks in PAvatar (dhooks.inc) }
  100. {$ENDIF}
  101.   ProcessParams;  { Parse command line parameters }
  102. {$IFNDEF ST}
  103.   FillArea(1,1,80,25,7,' ');  { Clear the screen }
  104. {$ENDIF}
  105.   Set_Sound_Backg(True);  { We want background music }
  106.   Assign(f,fname);
  107.   Reset(f,1);
  108.   repeat  { read and display the file }
  109.     BlockRead(f,buf,1024,z);
  110.     for i := 1 to z do begin
  111. {$IFNDEF ST}
  112.       Delay(slowdown);
  113. {$ENDIF}
  114.       Parse_AVT1(buf[i]);
  115.     end;
  116.   until EOF(f); { end else }
  117.   if Sounds_Left > 0 then begin
  118.     Writeln(' * Allowing music to finish * ');
  119.     Sound_Finish;  { Wait until all music has completed }
  120.   end;
  121. END.
  122.